package My.Nhom2.ServiceSearch;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MenuItemAdapter extends BaseAdapter {
	/** The context. */
	private Context context;

	/** The list result. */
	private List<ItemMenu> listresult;

	/**
	 * Instantiates a new service search adapter.
	 * 
	 * @param context1
	 *            the _context
	 * @param list
	 *            the list
	 */
	public MenuItemAdapter(final Context context1, final List<ItemMenu> list) {
		context = context1;
		listresult = list;

	}

	public int getCount() {
		// TODO Auto-generated method stub
		return listresult.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return listresult.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ItemMenu node = listresult.get(position);
		if (convertView == null) {
			LayoutInflater inflater = LayoutInflater.from(context);
			convertView = inflater.inflate(R.layout.itemmenu, null);
		}
		TextView tv_name = (TextView) convertView.findViewById(R.id.tv_detail);
		tv_name.setText(node.getTenChiTiet());

		TextView tv_price = (TextView) convertView.findViewById(R.id.tv_price);
		tv_price.setText(String.valueOf(node.getGiaTien()));
		//tv_price.setText("dffsfasd");

		TextView tv_note = (TextView) convertView.findViewById(R.id.tv_note);
		tv_note.setText(node.getChuThich());
		//tv_price.setText("dffsfasd");

		return convertView;
	}

}
